package com.yoomiito.app.widget;

import android.graphics.Rect;
import androidx.recyclerview.widget.RecyclerView;
import android.view.View;


/************************************************************
 * Author:  linqiang
 * Description:     // 模块描述
 * Date: 2019/5/1
 ************************************************************/
public class SupportSpacesItemDecoration extends RecyclerView.ItemDecoration {
    private int space;

    public SupportSpacesItemDecoration(int space) {
        this.space = space;
    }

    @Override
    public void getItemOffsets(Rect outRect, View view,
                               RecyclerView parent, RecyclerView.State state) {
        outRect.left = space;
        outRect.right = space;
        outRect.bottom = space;

        // Add top margin only for the first item to avoid double space between items
        if (parent.getChildPosition(view) == 0)
            outRect.top = space;
    }
}
